# Maintainer: Masanori Shirayama <mashir43@gmail.com>

pkgname=mksh
_ver=57
# use a pacman compatible version scheme
pkgver=${_ver/[a-z]/.${_ver//[0-9.]/}}
pkgrel=1
pkgdesc="The MirBSD Korn Shell"
arch=("i686" "x86_64")
url="https://www.mirbsd.org/mksh.htm"
license=('ISC')
depends=('gcc-libs')
makedepends=('gcc')
provides=('ksh')
conflicts=('ksh')
install=mksh.install
source=("https://www.mirbsd.org/MirOS/dist/mir/${pkgname}/${pkgname}-R${_ver}.tgz"
        "https://www.mirbsd.org/TaC-mksh.txt")
sha256sums=('3d101154182d52ae54ef26e1360c95bc89c929d28859d378cc1c84f3439dbe75'
            '92ea3319925b35081cb30ff3ef112dc6eff733cf63455b06c8eaae0adc03a400')

build() {
  cd "${srcdir}/${pkgname}"

  ./Build.sh
}

check() {
  cd "${srcdir}/${pkgname}"
  ./test.sh
}

package() {
  cd "${srcdir}/${pkgname}"

  mkdir -p "${pkgdir}/usr/bin"
  mkdir -p "${pkgdir}/usr/share/man/man1"
  mkdir -p "${pkgdir}/usr/share/licenses/mksh"

  cp -f mksh.exe ${pkgdir}/usr/bin
  cp -f mksh.1 ${pkgdir}/usr/share/man/man1

  cd "${srcdir}"
  cp -f TaC-mksh.txt ${pkgdir}/usr/share/licenses/mksh

  cd "${pkgdir}/usr/bin"
  cp -f mksh.exe ksh.exe
}
